home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / TCL1 / CDICTION / CSMARTDE.C < prev    next >
Text File  |  1989-09-15  |  5KB  |  156 lines

  1.  
  2.  
  3. #include "CSmartDesktop.h"
  4. #include "CSmartWindow.h"    /* for modal window support */
  5. #include "CBartender.h"
  6.  
  7. extern CBartender *gBartender;
  8. extern CBureaucrat    *gGopher;
  9. extern Boolean        gInBackground;
  10.  
  11. /**********************************************************************/
  12. void CSmartDesktop::ISmartDesktop(CBureaucrat *aSupervisor)
  13. {
  14.     CDesktop::IDesktop( aSupervisor);
  15.  
  16. }    /* CSmartDesktop::ISmartDesktop */
  17. /**********************************************************************/
  18. void CSmartDesktop::DispatchClick(register EventRecord *macEvent)
  19. {
  20.     Int16                    thePart;    /* Location of mouse click            */
  21.     WindowPeek                macWindow;    /* Window where click occurred        */
  22.     register CWindow        *theWindow;    /* Corresponding window object        */
  23.     register Int32            menuChoice;    /* Selection from a menu            */
  24.     
  25.     thePart = FindWindow(macEvent->where, &macWindow);
  26.     
  27.     if (macWindow != NULL) {
  28.         theWindow = (CWindow*) GetWRefCon(macWindow);
  29.         if (!theWindow) return;    /* DLP */
  30.     }
  31.     
  32.     /* DLP support for modal windows */
  33.     {
  34.         CSmartWindow *topWind = (CSmartWindow*) topWindow;
  35.         if (member( topWind, CSmartWindow))
  36.         {
  37.             if ((theWindow != topWind)&& topWind->IsModal())
  38.             {
  39.                 SysBeep(3);
  40.                 return;
  41.             }
  42.         }
  43.     }
  44.     
  45.     switch (thePart) {                    /* Take appropriate action            */
  46.     
  47.         case inDesk:                    /* Click on insignificant area of    */
  48.                                         /*   the Desktop                    */
  49.             CountClicks(this, macEvent);
  50.             DoClick(macEvent->where, macEvent->modifiers, macEvent->when);
  51.             break;
  52.         
  53.         case inMenuBar:                    /* Pull-down menus                    */
  54.             gBartender->UpdateAllMenus();
  55.             menuChoice = MenuSelect(macEvent->where);
  56.             if (HiShort(menuChoice)) {    /* A selection was made. Execute    */
  57.                                         /*   the corresponding command.        */
  58.                 gGopher->DoCommand(gBartender->FindCmdNumber
  59.                                     (HiShort(menuChoice), LoShort(menuChoice)));
  60.                 HiliteMenu(0);            /* Unhighlight the menu title        */
  61.             }
  62.             break;
  63.             
  64.         case inSysWindow:                /* Click inside a DA window            */
  65.             SystemClick(macEvent, macWindow);
  66.             break;
  67.             
  68.         case inContent:
  69.             if (!theWindow->active || ( (theWindow->floating &&
  70.                                 ((WindowPtr)macWindow != FrontWindow())))) {
  71.                                         /* This is an inactive window or    */
  72.                                         /*   an underlying floater            */
  73.                 theWindow->Select();
  74.                 
  75.                 if (!theWindow->actClick) {
  76.                     break;                /* Exit here unless window want to    */
  77.                 }                        /*   process activating click        */
  78.             }
  79.             
  80.             if (theWindow->wantsClicks) {
  81.                 UpdateWindows();        /* Window handles clicks. Make sure    */
  82.                                         /*   all windows are updated before    */
  83.                                         /*   responding to the click.        */
  84.                 theWindow->DispatchClick(macEvent);
  85.                 
  86.             } else {                    /* Window ignores clicks. Handle    */
  87.                                         /*   same as a click on the desktop    */
  88.                 CountClicks(this, macEvent);
  89.                 DoClick(macEvent->where, macEvent->modifiers, macEvent->when);
  90.             }
  91.             break;
  92.             
  93.         case inDrag:
  94.             theWindow->Drag(macEvent);
  95.             break;
  96.             
  97.         case inGrow:
  98.             theWindow->Resize(macEvent);
  99.             break;
  100.             
  101.         case inGoAway:
  102.             if (TrackGoAway(macWindow, macEvent->where))
  103.                 theWindow->Close();
  104.             break;
  105.             
  106.         case inZoomIn:
  107.         case inZoomOut:
  108.             if (TrackBox(macWindow, macEvent->where, thePart))
  109.                 theWindow->Zoom(thePart);
  110.             break;
  111.     }
  112.  
  113. }    /* CSmartDesktop::DispatchClick */
  114. /**********************************************************************/
  115. void CSmartDesktop::DispatchCursor(Point where, RgnHandle mouseRgn)
  116. {
  117.     WindowPeek        macWindow;            /* Window containing the mouse        */
  118.     CWindow            *theWindow;            /* Corresponding window object        */
  119.     Int16            thePart;            /* Part of window containing mouse    */
  120.     Rect            mbarRect;
  121.     
  122.     if (gInBackground) {                /* Do nothing if we are not the        */
  123.         return;                            /*   foreground process                */
  124.     }
  125.     
  126.                                         /* Determine which window contains    */
  127.                                         /*   the mouse                        */
  128.     thePart = FindWindow(where, &macWindow);
  129.     
  130.     if ( (thePart == inContent) || (thePart == inGrow) ) {
  131.                                         /* Mouse is within the content        */
  132.                                         /*   region of a window. Check if    */
  133.                                         /*   that window is active.            */
  134.             theWindow = (CWindow*) GetWRefCon(macWindow);
  135.             if (!theWindow) return;    /* DLP */
  136.             if (theWindow->IsActive()) {/* Window containing the mouse is    */
  137.                                         /*   active. Tell it to adjust the    */
  138.                                         /*   cursor shape.                    */
  139.                 theWindow->DispatchCursor(where, mouseRgn);
  140.                 return;                    /* Jump to end                        */
  141.             }
  142.                 
  143.     } else if (thePart == inMenuBar) {
  144.         SetCursor(&arrow);                /* Use arrow cursor in menu bar        */
  145.         mbarRect = screenBits.bounds;
  146.         mbarRect.bottom = mbarRect.top + GetMBarHeight();
  147.         RectRgn(mouseRgn, &mbarRect);
  148.         return;                            /* Jump to end                        */
  149.     }
  150.                                         /* All checks have failed. Mouse is    */
  151.                                         /* in some insignificant area of    */
  152.                                         /* the Desktop                        */
  153.     AdjustCursor(where, mouseRgn);        
  154. }    /* CSmartDesktop::DispatchCursor */
  155. /**********************************************************************/
  156.